<!--
 * @Author: your name
 * @Date: 2021-10-25 17:14:38
 * @LastEditTime: 2021-10-28 19:43:51
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \缘\domestic-service-platform\src\pages\bill\employee.vue
-->
<template>
  <div>
      <!-- 表格开始 -->
    <!-- 第一行开始 -->
    <div>
       <!-- 添加查询按钮 -->
    
      <el-form :inline="true" :model="Form" class="demo-form-inline">
         <el-date-picker
        value-format="timestamp"
        v-model="value2"
        type="datetimerange"
        :picker-options="pickerOptions"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
        align="right"
      ></el-date-picker>
        <el-form-item>
          <el-select v-model="Form.type" placeholder="请选择类型" clearable>
            <el-option label="收益" value="收益"></el-option>
            <el-option label="提现" value="提现"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-select v-model="Form.status" placeholder="请选择状态" clearable>
            <el-option label="正常" value="正常"></el-option>
            <el-option label="未审核" value="未审核"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-select placeholder="顾客编号" v-model="Form.employeeDataId" clearable>
            <el-option
              v-for="item in categoryData"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary"  @click='Onsearch'>查询</el-button>
        </el-form-item>
      </el-form>
    </div>
    <!-- 第一行结束 -->
    <!-- 第二行开始 -->
    <div>
      <el-table :data="Data" style="width: 100%">
        <el-table-column prop="id" label="编号" width="180"></el-table-column>
        <el-table-column prop="transferMoney" label="交易金额" width="180"></el-table-column>
        <el-table-column prop="transferTime" label="交易时间">
            <template slot-scope="scope">
                {{moment(scope.row.transferTime).format('YYYY-MM-DD hh:mm:ss')}}
            </template>
        </el-table-column>
        <el-table-column prop="type" label="交易类型">
        </el-table-column>
         <el-table-column prop="status" label="状态" width="180">
            <template slot-scope="scope">
               <el-tag type="warning" v-if='scope.row.status==="正常"'>正常</el-tag>
            </template>
        </el-table-column>
        <el-table-column prop="description" label="描述"></el-table-column>
      </el-table>
    </div>
    <!-- 第二行结束 -->
    <!-- 分页开始 -->
    <div>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="params.page"
        :page-sizes="[5, 10, 15, 20]"
        :page-size="params.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </div>
     <!-- 分页结束 -->
     <!-- 表格结束 -->
    
  </div>
</template>
<script>
let moment = require("moment");
import {EmployeeAccount } from "@/api/bill";
export default {
    // 组件名称
  name: "demo",
  // 组件参数 接收来自父组件的数据
  props: {},
  // 组件状态值
  data() {
    return {
      category: [],
      Form: {},
      form:{},
      employeeData: [],
      categoryData:[],
      Data:[],
      // 时间日期配置项
      pickerOptions: {
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            },
          },
           
        ],
      },
      formLabelWidth: "80px",
      value2: [],
      params: {
        page: 1,
        pageSize: 10,
      },
      total: 0,
      visible:false,
      title:''
    };
  },
  created(){
    this.employeePro();
    this.Employee();
    this.queryPageArticlesPro();
  },
   // 侦听器
  watch: {
    params: {
      handler() {
        this.employeePro();
        this.queryPageArticlesPro();
      },
      deep: true
    }
  },
  methods: {
    moment,
    //模糊查询 按条件查询
        async queryPageArticlesPro(){
            let temp={
                ...this.params,
                ...this.Form,
            }
            //属性名不存在 删除 temp-->name、id...
            for (let key in temp){
                if(!temp[key]){
                    delete temp[key];
                }
            }
            let res = await EmployeeAccount(temp);
            console.log(res);
            this.Data = res.data.list;
            this.total = res.data.total;  
        },
    //   给搜索按钮绑定事件
    Onsearch() {
      this.queryPageArticlesPro();
      
    },
    // 查询栏目分类信息
    async Employee() {
      let res = await EmployeeAccount(this.params);
      // console.log(res);
      this.categoryData = res.data.list;
    },
    //   分页查询顾客得数据
    async employeePro() {
      let temp = {
        ...this.params,
      };
      if (this.value2) {
        temp.beginTime = this.value2[0];
        temp.endTime = this.value2[1];
      }
      let res = await EmployeeAccount(temp);
      console.log(res);
      this.employeeData = res.data.list;
      this.total = res.data.total;
    },
    handleSizeChange(pageSize) {
      this.params.pageSize = pageSize;
    },
    handleCurrentChange(page) {
      this.params.page = page;
    },
  },
};
</script>
<style lang="scss">